package handler

import (
	"github.com/gin-gonic/gin"
	"tvmanager/model"
)

func AddNews(c *gin.Context) {
	title := c.PostForm("title")
	author := c.PostForm("author")
	data := model.News{
		Title:  title,
		Author: author,
	}
	model.DB.Create(&data)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "OK",
	})
	return
}
func NewsList(c *gin.Context) {
	var news []model.News
	model.DB.Find(&news).Debug()
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "OK",
		"data": news,
	})
	return
}
